 #include("common.html")
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>商城</title>
    
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="full-screen" content="yes">
    <meta name="x5-fullscreen" content="true">
    <link rel="stylesheet" type="text/css" href="#(tpath)/static/css/vant.css">
    <link rel="stylesheet" type="text/css" href="#(tpath)/static/css/filter.css">
    <script type="text/javascript" src="#(tpath)/static/js/jquery.js"></script>
  </head>
  
  <body class="">
  <div class="van-dialog__content" style="    margin-bottom: 20px;">
  	<div style="padding: 10px;">当前余额：#(member.amount??"0.00")
  	</div>
    <div style="padding: 10px;">#if(member.accountType=='Wechat')微信#else if(member.accountType=='Alipay')支付宝#else if(member.accountType=='Bank')银行#end账户：#(member.zh)
      <button class="van-button van-button--primary van-button--mini" slot="button" style="margin-left: 5px;" onclick="location.href='#(base)/member/account'">
        <span class="van-button__text">修改提现</span></button>
    </div>
    <div class="van-cell van-field">
      <!---->
      <div class="van-cell__title">
        <span>提现金额</span>
        <!----></div>
      <div class="van-cell__value">
        <div class="van-field__body">
          <input type="text" placeholder="请输入提现金额" class="van-field__control" id="inputAmount" memberAmount="#(member.amount??'0.00')">
          <!---->
          <!---->
          <!----></div>
        <!----></div>
      <!----></div>
    <div style="padding: 10px 10px 0px; color: rgb(68, 187, 0); font-size: 0.8rem;">提现需要财务审核，请耐心等待</div></div>
	<div class="submitBox">
          <button class="submit van-button van-button--primary van-button--large" id="quedingBtn">
            <span class="van-button__text">确认</span></button>
        </div>
</body>
</html>
<script type="text/javascript">
$("#inputAmount").on("blur",function(){
	var money = $("#inputAmount").val();
	var priceReg = /((^[1-9]\d*)|^0)(\.\d{0,2}){0,1}$/;
	if (!priceReg.test(money)){
	  return false;
	}
	var memberAmount = $("#inputAmount").attr("memberAmount");
	if(parseFloat(money)>parseFloat(memberAmount)){
		return false;
	}
	var rate = $("#rate").html();
	var rmb = parseFloat(money)*parseFloat(rate);
	$("#rmb").html(Math.floor(rmb * 100) / 100);
	
});

$("#quedingBtn").on("click",function(){
	var money = $("#inputAmount").val();
	var priceReg = /((^[1-9]\d*)|^0)(\.\d{0,2}){0,1}$/;
	if (!priceReg.test(money)){
	   alert("请输入正确的提现金额");
	  return false;
	}
	var memberAmount = $("#inputAmount").attr("memberAmount");
	if(parseFloat(money)>parseFloat(memberAmount)){
		alert("提现金额不能大于当前余额");
		return false;
	}
	$.ajax({
        url: "#(base)/member/withdraw/saveApply",
        type: "post",
        data: {"amount":money},
        dataType: "json",
        success: function(res){
        	if(res.type=="success"){
       			location.href="#(base)/member/withdraw/list"
       		}else{
       			alert(res.msg);
       		}
        },
        error: function(res){
        }
    });
});
</script>